﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static WEBWeixinSDK.WXInit;

namespace WEBWeixinSDK.WXMod
{
    /// <summary>
    /// 获取所有用户返回的对象
    /// </summary>
    public class WXMember
    {
        public BaseResponse BaseResponse { get; set; }
        /// <summary>
        /// MemberCount
        /// </summary>
        public int MemberCount { get; set; }
        /// <summary>
        /// MemberList
        /// </summary>
        public List<MemberObj> MemberList { get; set; }
        /// <summary>
        /// 普通用户列表
        /// </summary>
        public List<MemberUser> MemberListUser { get; set; }
        /// <summary>
        /// 公众号列表
        /// </summary>
        public List<MemberGroup> MemberListGroup { get; set; }
        /// <summary>
        /// 群聊列表
        /// </summary>
        public List<GroupChat> GroupChatList { get; set; }
        /// <summary>
        /// 个人列表
        /// </summary>
        public List<Userer> UsererList { get; set; }
        /// <summary>
        /// Seq
        /// </summary>
        public int Seq { get; set; }


        /// <summary>
        /// 普通成员
        /// </summary>
        public List<MemberObj> NormalMember = new List<MemberObj>();

        /// <summary>
        /// 公众号
        /// </summary>
        public List<MemberObj> PublicMember = new List<MemberObj>();

        /// <summary>
        /// 群聊
        /// </summary>
        public List<MemberObj> GroupMember = new List<MemberObj>();
        /// <summary>
        /// 其他用户
        /// </summary>
        public List<MemberObj> OtherMember = new List<MemberObj>();

        /// <summary>
        /// 对用户进行分类
        /// </summary>
        public void SortMembers()
        {
            if (MemberList != null)
            {
                foreach (MemberObj oneMem in MemberList)
                {
                    if (((int)oneMem.VerifyFlag & 8) != 0)
                    {

                        PublicMember.Add(oneMem);
                    }
                    else if (special_users.Contains(oneMem.UserName))
                    {

                        OtherMember.Add(oneMem);


                    }
                    else if (oneMem.UserName.IndexOf("@@") != -1)
                    {

                        GroupMember.Add(oneMem);

                    }
                    else
                    {

                        NormalMember.Add(oneMem);

                    }
                }
            }
        }
        /// <summary>
        /// 系统微信用户名
        /// </summary>
        public static string[] special_users = new string[]{"newsapp", "fmessage", "filehelper", "weibo", "qqmail",
                         "fmessage", "tmessage", "qmessage", "qqsync", "floatbottle",
                         "lbsapp", "shakeapp", "medianote", "qqfriend", "readerapp",
                         "blogapp", "facebookapp", "masssendapp", "meishiapp",
                         "feedsapp", "voip", "blogappweixin", "weixin", "brandsessionholder",
                         "weixinreminder", "wxid_novlwrv3lqwv11", "gh_22b87fa7cb3c",
                         "officialaccounts", "notification_messages", "wxid_novlwrv3lqwv11",
                         "gh_22b87fa7cb3c", "wxitil", "userexperience_alarm", "notification_messages"};
    }
}
